//
//  UIImage+Extension.swift
//  01图片选择器
//
//  Created by 龚欣 on 15/7/10.
//  Copyright © 2015年 gong. All rights reserved.
//

import UIKit
extension UIImage {

    func scaleImage(width : CGFloat) -> UIImage {
        let scale = size.height / size.width
        let height = width * scale
        
        UIGraphicsBeginImageContext(CGSize(width: width, height: height))
        
        drawInRect(CGRect(x: 0, y: 0, width: width, height: height))
        
        let result = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return result
    
    }
}
